package cn.gok.day2;

import java.util.Scanner;

/**
 * @ClassName SuperWorker
 * @Description TODO
 * @Author HP
 * @Date 19:26 2022/7/5
 * @Version 1.0
 *
 * 定义SuperWorker类，派生于Worker类，增加 float bonus成员变量//奖金系数  ,范围在  【0,1】之间
 *  * 重写父类的doJob方法，  返回:总工资=普通工人总工资*(1+奖金系数)
 *  *
 *  * 同时重载doJob方法增加入参addtionalHours(加班总工时），即
 *  *    public  int  doJob(int months,int addtionalHours){
 *  *          //返回不带加班时间的doJob返回值 +  bonus*salary*addtionalHours/100
 *  *    }
 *  * 在main中创建1个SuperWorker对象，调用两个doJob方法
 **/
public class SuperWorker extends Worker{
    private float bonus;
    private Scanner scanner=new Scanner(System.in);
    public float getBonus() {
        return bonus;
    }

    public void setBonus() {
        System.out.println("请输入您的奖金系数：");
        float bonus=scanner.nextFloat();
        if(bonus<1&&bonus>0){
            this.bonus = bonus;
        }else{
            System.out.println("只可以是0-1之间哦~");
            this.setBonus();
        }

    }

    public SuperWorker(float bonus) {
        this.bonus = bonus;
    }

    public SuperWorker(String name, String job, int salary) {
        super(name, job, salary);
    }


    @Override
    public String toString() {
        return "SuperWorker{" +
                "bonus=" + bonus +
                '}';
    }

    @Override
    public int doJob(int months) {
        return (int)(super.doJob(months)*(1+this.bonus));
    }
    public  int  doJob(int months,int addtionalHours){
        return (int)(doJob(months)+bonus*this.getSalary()*addtionalHours/100);
    }

    public static void main(String[] args) {
        SuperWorker superWorker=new SuperWorker("Osar","java开发工程师",3000);
        superWorker.doJob(2);
        superWorker.setBonus();
        System.out.println(superWorker.getName()+"工作了"+2+"个月,获得了"+superWorker.doJob(2,20)+"工资");

    }
}
